<?php include 'header1.php'; ?>
<?php include '../settings.php'; ?>
<?php
//$con=mysqli_connect("localhost","quran","quran","Quran-Simple");


$con=mysqli_connect($host,$dbuserW,$dbpassW,$dbname);

//a counter for descriptions not needed for anything except giving it form of array in posting
$descriptions=1;
$sura=$_GET["Sura"];
if  ($sura==0) $sura=1;
if ($sura==115)  header("Location: /categories.php");
if ($sura==116)  header("Location: /admin/import.php");

//Sura navigation And other navigation later
echo "<form id='page-changer' action='' method='get'><select name='Sura'>";
echo "<option value='0'>Select</option>";
echo "<option value='115'>Categories</option>";
echo "<option value='116'>Import</option>";
$suras = mysqli_query($con,"select  number,name from suranames ;");
while($row = mysqli_fetch_array($suras)) 
{
if ($row['number']==$sura) echo("<option value='".$row['number']."' selected='selected'>".$row['name']."</option>");
else echo("<option value='".$row['number']."'>".$row['name']."</option>");
}
//<option value='1'>CSS-Tricks</option>       
echo "</select><input type='submit' value='GoTo' id='submit' /></form>";



//Begining of form that is the whole page
echo "<form name='myWebForm' action='".$adminlocation."postsuraconnection.php' method='post'><table border='1' style='width:100%'>";


//$con=mysqli_connect("localhost","quran","quran","Quran");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}


//Do controls twice once to set a placeholder so the floating does not cover first aya
//for ($x=1;$x<=1;$x++)
//{
echo "<div class='floating-menu'>";

echo "\n";
echo "مسح تصنيف علي ايه:<input type='checkbox' name='Delete' value='delete'  />";
echo "|";
echo "تخبأه تصنيف علي ايه:<input type='checkbox' name='Ban' value='ban'  />";
//echo "<br>";
echo "|";

echo "تخبأه تصنيف تماما:<input type='checkbox' name='BanCat' value='bancat'  />";
echo "|";
echo "تغير تصنيف علي ايات الي تصنيف اخر تختاره من ادني:<input type='checkbox' name='ChangeCat' value='changecat'  />";

echo "<br>";


echo("تصنيف جديد: <input type='text' name='NewCategory'><br>");

echo("<input type='hidden' name='SuraNum' value='".$sura."'>");
 

$Cats = mysqli_query($con,"select CIndex,Description from Category  where Banned=0 order by Description ASC;");

echo "<div class='ui-widget'>";
echo("<select id='combobox' name='CategorySelected'>");
echo("<option value=''>Select One</option>");

while($row = mysqli_fetch_array($Cats)) 
{
echo("<option value='".$row['CIndex']."'>".$row['Description']."</option>");
}

echo("</select></div><br><input type='submit' value='Submit'>");
//echo "<a href='#ee' id='toggle'>Show Normal Select</a>";

echo "</div>";
//echo "<button id='toggle'>Show underlying select</button>";


//}

echo "<div class='floating-menuspaceholder'> </div>";


//end controls

echo "<A class='anchor' name='start'></a>";


$thiscat=$_GET['Category'];

$result=mysqli_query($con,"Select quran_text2.index,quran_text2.sura,quran_text2.aya,quran_text2.text,suranames.name  from suranames,CategoryAya,quran_text2 where CategoryAya.Banned=0 and quran_text2.sura=suranames.number and  quran_text2.index=CategoryAya.AyaIndex and CategoryAya.CategoryIndex='".$thiscat."' order by quran_text2.index");

while($row = mysqli_fetch_array($result)) 
{

	echo "<tr><td width='100%'>";
	echo "<A class='anchor' name='".$row['index']."'></a><A class='anchor' name='".$row['index'].",".$row['sura'].",".$row['aya']."'></a><input type='checkbox' name='Aya[".$row['aya']."]' value='".$row['index'].",".$row['sura'].",".$row['aya']."' id='add".$row['index']."' />(".$row['aya'] . ") <label for='add".$row['index']."'><div id='Quran'>" . $row['text']."</div></label><br>";
	$getrelatedcatsquery="Select Category.Description,Category.CIndex from CategoryAya,Category where Category.Banned=0 and CategoryAya.Banned=0 and CategoryAya.AyaIndex='".$row['index']."'  and Category.CIndex=CategoryAya.CategoryIndex";
	//echo ("<br>".$getrelatedcatsquery);
	$relatedcats=mysqli_query($con,$getrelatedcatsquery);
	while ($SmallCat=mysqli_fetch_array($relatedcats))
	{
	$descriptions++;
	echo ("<input type='checkbox' name='dels[".$descriptions."]' value='".$SmallCat['CIndex'].",".$row['index']."'  />");
	echo ("<a href='".$applocation."category.php?category=".$SmallCat['CIndex']."'>");
	echo ($SmallCat['Description']."</a><br>");
	}
	echo "<a href='#start'>^</a></td></tr>";
	echo "\n";

}
echo "</table></select><br><input type='submit' value='Submit'></form>";

mysqli_close($con);
?> 

<?php include 'footer.php'; ?>


